package com.environment_pro.monitor.tld;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.environment_pro.monitor.service.BaseService;
import com.environment_pro.monitor.util.StaticUtil;

public class Id2name extends TagSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6385987901308941452L;
	
	private int objectId ;
	
	public int getObjectId() {
		return objectId;
	}

	public void setObjectId(int objectId) {
		this.objectId = objectId;
	}

	private String objectType ;
	
	public String getObjectType() {
		return objectType;
	}

	public void setObjectType(String objectType) {
		this.objectType = objectType;
	}

	public int doStartTag() throws JspException {
		try {
			JspWriter out = pageContext.getOut();
			BaseService baseService = (BaseService) StaticUtil.getBean(objectType+"Service");
			String name = baseService.id2name(objectId);
			out.print(name);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return super.doStartTag();
	}

}
